package com.yanfan.alarm.service.impl;

import java.util.Arrays;
import java.util.List;
import com.yanfan.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanfan.alarm.mapper.NjDefenceAreaInfoMapper;
import com.yanfan.alarm.domain.NjDefenceAreaInfo;
import com.yanfan.alarm.service.INjDefenceAreaInfoService;

/**
 * 防区状态Service业务层处理
 *
 * @author genluo
 * @date 2024-10-31
 */
@Service
public class NjDefenceAreaInfoServiceImpl extends ServiceImpl<NjDefenceAreaInfoMapper, NjDefenceAreaInfo> implements INjDefenceAreaInfoService {
    @Autowired
    private NjDefenceAreaInfoMapper njDefenceAreaInfoMapper;


    /**
     * 查询防区状态列表
     *
     * @param njDefenceAreaInfo 防区状态
     * @return 防区状态
     */
    @Override
    public List<NjDefenceAreaInfo> queryPageList(NjDefenceAreaInfo njDefenceAreaInfo) {
        LambdaQueryWrapper<NjDefenceAreaInfo> lqw = buildQueryWrapper(njDefenceAreaInfo);
        return njDefenceAreaInfoMapper.selectList(lqw);
        //连表查询可用该方法，在此方法SQL语句上进行扩展
        //return njDefenceAreaInfoMapper.queryPageList(njDefenceAreaInfo);
    }

    /**
    * 分页查询条件
    * @return
    */
    private LambdaQueryWrapper<NjDefenceAreaInfo> buildQueryWrapper(NjDefenceAreaInfo bo) {
        LambdaQueryWrapper<NjDefenceAreaInfo> lqw = Wrappers.lambdaQuery();
        lqw.like(StringUtils.isNotBlank(bo.getDefenceAreaName()), NjDefenceAreaInfo::getDefenceAreaName, bo.getDefenceAreaName());
        lqw.eq(bo.getStatus() != null, NjDefenceAreaInfo::getStatus, bo.getStatus());
        lqw.eq(bo.getIsOnline() != null, NjDefenceAreaInfo::getIsOnline, bo.getIsOnline());
        lqw.eq(bo.getByPass() != null, NjDefenceAreaInfo::getByPass, bo.getByPass());
        lqw.eq(bo.getDefenceAreaType() != null, NjDefenceAreaInfo::getDefenceAreaType, bo.getDefenceAreaType());
        //lqw.eq(StringUtils.isNotBlank(bo.getUpdateType()), NjDefenceAreaInfo::getUpdateType, bo.getUpdateType());
        return lqw;
    }



}
